from django.conf.urls import patterns, url
from malachite.models import Post
from malachite.views import (HybridPostsListView,
                             HybridPostDetailView,
                             HybridPostsbyTagListView,
                             ContactFormView,
                             )
from malachite.auth_views import user_login, user_logout


urlpatterns = patterns(
    'malachite.views',

    url(r'^posts/$', HybridPostsListView.as_view(
        queryset=Post.objects.order_by("-published"),
        context_object_name="posts_list",
        )),

    url(r'^posts/(?P<pk>\d+)$', HybridPostDetailView.as_view(
        model=Post,
        context_object_name="post",
        )),

    url(r'^tags/([\w\-,]+)$', HybridPostsbyTagListView.as_view(
        model=Post,
        context_object_name="posts_list",
        )),

    url(r'^contact/$', ContactFormView.as_view()),

    # Administrative views
    url(r'/login/$', user_login, name='login'),
    url(r'/logout/$', user_logout, name='logout'),
    )
